﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
    CodeBehind="S_Print.aspx.cs" Inherits="JTicket.UI.S_Print" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/jscript">
        $(document).ready(
    function () {

        $("#flag").val(Request("ordercode"));
        $("#st").val(Request("TitleCode"));
        JTicket.UI.Service.JT_TicketOperateSvc.GetSQL(
        function Success(Result) {
            try {
                document.forms[0].FastReport.AddConnectionStr(Result);
            } catch (e) {
                alert('客户端打印控件(SevReport.dll)没有安装,请在帮助中心中下载客户端打印控件后安装。');
                window.location.href = "JT_MainPanel.aspx";
            }
        },
        function Fail() {
            alert("数据库连接失败"); $("#SQLHide").val("");
        });
    });          //--关闭IE窗体事件
        function window.onunload() {
            try {
                tt = document.forms[0].FastReport.CloseADOConnect();
                tt = document.forms[0].FastReport.CloseProc();
                tt = document.forms[0].FastReport.FreeReport();
            }
            catch (e) {
            }
        }
        //重打印
        function IsExt(a, b) {
            if (confirm("是否打印所选票！")) {
                var ResList = new Array();
                $.ajax({
                    type: "get",
                    url: "Reprint.axd?BarList=" + a
                    + "&StitleCode=" + $("#st").val() + "&flag="
                    + $("#flag").val() + "&Time=" + new Date(),

                    success: function (msg) {
                        switch (msg) {

                            case "0":
                                alert('未审核打印操作!');
                                break;
                            case "-1":
                                alert('打印失败,请重新操作!');
                                break;
                            default:
                                try {
                                    ResList = msg.toString().split('|');
                                    if (ResList != null) {
                                        for (var j = 0; j < ResList.length; j++) {
                                            document.forms[0].FastReport.ClearAllSqlCommand();
                                            document.forms[0].FastReport.CloseProc();
                                            document.forms[0].FastReport.AddSqlCommand(ResList[j]);
                                            var PrintTemplate = "";
                                            PrintTemplate = "C:\\BarCode\\BarCode.fr3";
                                            document.forms[0].FastReport.PrintReportEx(PrintTemplate, 0, 0);
                                        }
                                        alert('恭喜：重打印成功!');
                                    }
                                } catch (e) {
                                }
                                break;
                        }
                        window.location.reload(); //重新加载该页面
                    },
                    error: function () { isAlertError(); }
                });
            }
        }
        //重打印
        function IsExts() {
            if (confirm("是否打印所选票！")) {
                var ResList = new Array();
                $.ajax({
                    type: "get",
                    url: "Reprint.axd?BarList=" + CheckValue()
                    + "&StitleCode=" + $("#st").val() + "&flag="
                    + $("#flag").val() + "&Time=" + new Date(),
                    success: function (msg) {
                        switch (msg) {
                            case "0":
                                alert('未审核打印操作!');
                                break;
                            case "-1":
                                alert('打印失败,请重新操作!');
                                break;
                            default:
                                try {
                                    ResList = msg.toString().split('|');
                                    if (ResList != null) {
                                        for (var j = 0; j < ResList.length; j++) {
                                            document.forms[0].FastReport.ClearAllSqlCommand();
                                            document.forms[0].FastReport.CloseProc();
                                            document.forms[0].FastReport.AddSqlCommand(ResList[j]);
                                            var PrintTemplate = "";
                                            PrintTemplate = "C:\\BarCode\\BarCode.fr3";
                                            document.forms[0].FastReport.PrintReportEx(PrintTemplate, 0, 0);
                                        }
                                        alert('恭喜：重打印成功!');
                                    }
                                } catch (e) {
                                }
                                break;
                        }
                        window.location.reload(); //重新加载该页面
                    },
                    error: function () { isAlertError(); }
                });
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="sm" runat="server">
        <Services>
            <asp:ServiceReference InlineScript="true" Path="~/Service/JT_TicketOperateSvc.asmx" />
        </Services>
    </asp:ScriptManager>
    <input type="hidden" id="flag" />
    <input type="hidden" id="st" />
    <table align="center" cellpadding="4" cellspacing="1" border="1" width="100%" class="toptable grid fixed">
        <tr>
            <td class="category t2" style="width: 629px; height: 25px;">
                重打印票
            </td>
            <td class="category" style="height: 25px">
                <input type="button" id="Button1" value="重打印" onclick="IsExts();" onmousemove="showBtnOver(this)"
                    onmouseout="showBtnOut(this)" class="submitMiniGreen" />
            </td>
        </tr>
    </table>
    <table cellpadding="1" cellspacing="1" id="TbInfo" class="TbInfo">
        <tr>
            <td class="B" style="width: 4%">
                选择
            </td>
            <td class="B" style="width: 4%">
                序号
            </td>
            <td class="B" style="width: 10%">
                条形码
            </td>
            <td class="B" style="width: 9%">
                剧院
            </td>
            <td class="B" style="width: 6%">
                单价
            </td>
            <td class="B">
                演出名称
            </td>
            <td class="B" style="width: 8%">
                场次
            </td>
            <td class="B" style="width: 9%">
                演出单位
            </td>
            <td class="B" style="width: 8%">
                销售员
            </td>
            <td class="B" style="width: 4%">
                排号
            </td>
            <td class="B" style="width: 4%">
                座位号
            </td>
            <td class="B" style="width: 5%">
                描述
            </td>
            <td class="B" style="width: 5%">
                区域
            </td>
            <td class="B" style="width: 5%">
                票类
            </td>
            <td class="B" style="width: 5%">
                重打印
            </td>
        </tr>
        <%int i = 1;%>
        <%foreach (var x in _pb)
          {%>
        <%i += 1;%>
        <tr>
            <td class="td1">
                <input name="cb" class="checkbox" type="checkbox" value="<%=x.barcode%>" style="border: 0" />
            </td>
            <td class="td1">
                <%=i.ToString()%>
            </td>
            <td class="td1">
                <%=x.barcode%>
            </td>
            <td class="td1">
                <%=x.ThName%>
            </td>
            <td class="td1">
                <%=x.Price.ToString()%>
            </td>
            <td class="td1">
                <%=x.TitleName%>
            </td>
            <td class="td1">
                <%=x.TitleNum%>
            </td>
            <td class="td1">
                <%=x.Steam%>
            </td>
            <td class="td1">
                <%=x.opercode%>
            </td>
            <td class="td1">
                <%=x.Pnum%>
            </td>
            <td class="td1">
                <%=x.Znum%>
            </td>
            <td class="td1">
                <%=x.MSg%>
            </td>
            <td class="td1">
                <%=x.Area%>
            </td>
            <td class="td1">
                <%=x.Ticketname%>
            </td>
            <td class="td2">
                <img alt="重打印" src="images/print.gif" onclick="IsExt('<%=x.barcode%>','<%=x.TitleCode%>');"
                    style="cursor: hand;" />
            </td>
        </tr>
        <%}%>
    </table>
    <object classid="clsid:3F9223A8-3B4E-4C01-A1F2-DEB35CA34E68" name="FastReport" style="z-index: 105;
        width: 0px; height: 0px">
    </object>
</asp:Content>
